<template>
	<view>
		<view class="flex-col flex-1 group_3">
			<image class="shrink-0 image_4" :src="formdata.photo" />
			<view class="flex-col relative section">
				<text class="self-start text">{{ formdata.companyName }}</text>
				<view class="flex-col self-stretch group_4">
					<view class="flex-row items-center self-stretch group_5">
						<view class="section_2"></view>
						<text class="font ml-9">公司信息</text>
					</view>
					<text class="self-stretch text_2">
						{{ formdata.introduce }}
					</text>
					<view class="self-stretch divider"></view>
					<text class="self-start font_2 text_3">地址</text>
					<text class="self-start text_4">{{ formdata.companyAddress }}</text>
				</view>
				<view class="flex-col items-start self-stretch group_5 view">
					<text class="font_2">地图</text>
					<map style="
              width: 100%;
              height: 320rpx;
              border-radius: 16rpx 16rpx 16rpx 16rpx;
              margin-top: 28rpx;
              overflow: hidden;
            " :latitude="formdata.lng" :longitude="formdata.lat">
					</map>
				</view>
			</view>
			<view class="flex-col section_3">
				<view class="flex-col justify-start items-center button text-wrapper" @click="handleToChat(formdata.userId)">
					<text class="font text_5">聊一聊</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import petChecked from "../../../../api/petChecked.js";
	export default {
		data() {
			return {
				id: "",
				formdata: {
					companyName: "",
					companyAddress: "",
					photo: "",
					license: "",
					introduce: "",
					lat: 0,
					lng: 0,
				},
			};
		},
		onLoad(option) {
			this.getDetail(option.id);
		},
		methods: {
			getDetail(id) {
				petChecked
					.getPetCompanyById(id)
					.then((res) => {
						if (res.code === 200) {
							this.formdata = res.data;
						} else {
							uni.showToast({
								title: "请求失败",
								icon: "none",
							});
						}
						console.log(res);
					})
					.catch((err) => {
						uni.showToast({
							title: "请求失败",
							icon: "none",
						});
						console.log(err);
					});
			},
			handleToChat(id) {
				uni.navigateTo({
					url: '/pages/news/user-chat/user-chat?userId=' + id
				})
			}
		},
	};
</script>

<style lang="scss" scoped>
	.ml-9 {
		margin-left: 18rpx;
	}

	.mt-11 {
		margin-top: 22rpx;
	}

	.group_3 {
		overflow-y: auto;

		.image_4 {
			width: 100vw;
			height: 56.2667vw;
		}

		.section {
			margin: -108rpx 32rpx 0;
			padding: 60rpx 0 32rpx;
			background-color: #ffffff;
			border-radius: 24rpx;
			z-index: 99;

			.text {
				margin-left: 40rpx;
				color: #000000;
				font-size: 48rpx;
				font-family: PingFang SC;
				font-weight: 700;
				line-height: 44.88rpx;
			}

			.group_4 {
				margin-top: 56rpx;

				.text_2 {
					margin: 20rpx 40rpx 0 32rpx;
					color: #999999;
					font-size: 28rpx;
					font-family: PingFang SC;
					line-height: 34rpx;
				}

				.divider {
					margin-top: 32rpx;
					background-color: #f6f6f6;
					height: 8rpx;
				}

				.text_3 {
					margin-left: 32rpx;
					margin-top: 40rpx;
					line-height: 21.6rpx;
				}

				.text_4 {
					margin-left: 32rpx;
					margin-top: 28rpx;
					color: #000000;
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 700;
					line-height: 26.12rpx;
				}
			}

			.group_5 {
				padding: 0 32rpx;

				.section_2 {
					background-color: #fbd610;
					border-radius: 6rpx;
					width: 8rpx;
					height: 40rpx;
				}

				.image_5 {
					border-radius: 16rpx;
					width: 622rpx;
					height: 320rpx;
				}
			}

			.view {
				margin-top: 44rpx;
			}

			.font_2 {
				font-size: 24rpx;
				font-family: PingFang SC;
				line-height: 22rpx;
				color: #999999;
			}
		}

		.section_3 {
			margin-top: 30rpx;
			padding: 18rpx 0;
			background-color: #ffffff;
			border-top: solid 2rpx #f6f6f6;

			.button {
				margin: 0 32rpx;

				.text_5 {
					line-height: 29.72rpx;
				}
			}

			.text-wrapper {
				padding: 28rpx 0;
				background-color: #fbd610;
				border-radius: 68rpx;
				overflow: hidden;
			}
		}

		.font {
			font-size: 32rpx;
			font-family: PingFang SC;
			line-height: 29.92rpx;
			font-weight: 700;
			color: #000000;
		}
	}
</style>